package com.laamella.syntherface.synths.alesis.micron.model;

import com.laamella.syntherface.synths.midi.MidiInterface;
import com.laamella.syntherface.synths.models.NrpnParameterModel;
import com.laamella.syntherface.synths.models.ParameterModel;
import com.laamella.syntherface.synths.models.ParameterType;
import com.laamella.syntherface.synths.models.ParameterType.IntegerRange;

public final class Filters {

	public final ParameterModel filter1Type;
	public final ParameterModel filter1Frequency;
	public final ParameterModel filter1Resonance;
	public final ParameterModel filter1KeyTrack;
	public final ParameterModel filter1EnvelopeAmount;

	public final ParameterModel filter2Type;
	public final ParameterModel filter2Offset;
	public final ParameterModel filter2FrequencyAbsolute;
	public final ParameterModel filter2FrequencyRelative;
	public final ParameterModel filter2Resonance;
	public final ParameterModel filter2KeyTrack;
	public final ParameterModel filter2EnvelopeAmount;

	private static final ParameterType FilterTypes = new ParameterType.List("bypass, mg 4-pole lowpass, ob 2-pole lowpass, ob 2-pole bandpass, "
			+ "ob 2-pole highpass, rp 4-pole lowpass, tb 3-pole lowpass, "
			+ "jp 4-pole lowpass, 8-pole lowpass, 8ve dual bandpass, 6-pole bandpass, "
			+ "phase warp, comb filter 1, comb filter 2, vocal formant 1, " + "vocal formant 2, vocal formant 3, bandlimit, op 4-pole highpass, "
			+ "comb filter 3, comb filter 4");
	private static final ParameterType FilterFrequencyType = new ParameterType(0, 1023) {
		@Override public String format(int value) {
			// TODO correct
			return "???" + value + "Hz";
		}
	};
	private static final IntegerRange KeyTrackType = new ParameterType.IntegerRange(-100, 200);
	private static final IntegerRange RelativeFilterFrequencyType = new ParameterType.IntegerRange(-400, 400);

	Filters(MidiInterface midiInterface) {
		filter1Type = new NrpnParameterModel("filter 1 type", midiInterface, 43, FilterTypes);
		filter1Frequency = new NrpnParameterModel("filter 1 frequency", midiInterface, 44, FilterFrequencyType);
		filter1Resonance = new NrpnParameterModel("filter 1 resonance", midiInterface, 45, ParameterType.Percentage);
		filter1KeyTrack = new NrpnParameterModel("filter 1 key track", midiInterface, 46, KeyTrackType);
		filter1EnvelopeAmount = new NrpnParameterModel("filter 1 envelope amount", midiInterface, 47, ParameterType.PercentageAlsoNegative);
		filter2Offset = new NrpnParameterModel("filter 2 relative to 1", midiInterface, 48);
		filter2Type = new NrpnParameterModel("filter 2 type", midiInterface, 49, FilterTypes);
		filter2FrequencyAbsolute = new NrpnParameterModel("filter 2 frequency absolute", midiInterface, 50, FilterFrequencyType);
		filter2FrequencyRelative = new NrpnParameterModel("filter 2 frequency relative", midiInterface, 158, RelativeFilterFrequencyType);
		filter2Resonance = new NrpnParameterModel("filter 2 resonance", midiInterface, 51, ParameterType.Percentage);
		filter2KeyTrack = new NrpnParameterModel("filter 2 key track", midiInterface, 52, KeyTrackType);
		filter2EnvelopeAmount = new NrpnParameterModel("filter 2 envelope amount", midiInterface, 53, ParameterType.PercentageAlsoNegative);
	}
}